package com.landking.home.foot;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.landking.R;
import com.landking.home.pic.domain.PicStc;
import com.landking.http.HttpValues;
import com.landking.utils.PrefUtils;

import java.util.List;

import cn.jzvd.JZVideoPlayerStandard;


/**
 * Created by 1013369768 on 2017/5/27.
 */

public class VideoAdapter extends BaseAdapter {
    private Context context;
    private LayoutInflater mInflater;
    private String http_ip;
    private String[] videoUrlList;

    private static final RequestOptions BANNER_OPTIONS = new RequestOptions()
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .dontAnimate()
            // .fitCenter()
            .centerCrop()
            //.placeholder(R.drawable.ic_launcher)
            ;

    public VideoAdapter(Context context,String http_ip, String[] videoUrlList) {
        this.context = context;
        this.mInflater = LayoutInflater.from(context);
        this.http_ip = http_ip;
        this.videoUrlList = videoUrlList;
    }

    @Override
    public int getCount() {
        return videoUrlList.length;
    }

    @Override
    public Object getItem(int position) {
        return videoUrlList[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_video_list, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.video = (JZVideoPlayerStandard) convertView.findViewById(R.id.videoplayer);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        String videourl = videoUrlList[position];


        viewHolder.video.setUp(http_ip+"/landking/video/01人妻Ntr篇/"+videourl,
                JZVideoPlayerStandard.SCREEN_WINDOW_NORMAL,
                "");


        // viewHolder.video.setUp(http_ip+"/landking/video/01人妻Ntr篇/"+videourl, videourl, Jzvd.SCREEN_NORMAL);
        // 播放前页显示图片我简单的设置了一下。
        // 推荐同学们使用Glide加载网络图片或本地图片，Glide优点明显
        // viewHolder.video.posterImageView.setImageResource(R.mipmap.ic_launcher_round);
        return convertView;
    }

    private static class ViewHolder {
        public JZVideoPlayerStandard video;
    }
}
